<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('评分记录列表')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>评分记录列表
                <!-- 显示用户名信息 -->
                <small th:if="${not #strings.isEmpty(userName)}" class="ml-3 text-muted">
                    当前查看：<span th:text="${userName}" class="text-primary"></span> 的评分记录
                </small>
            </h5>
        </div>
        <div class="ibox-content">
            <div class="table-responsive">
                <table class="table table-striped table-bordered table-hover dataTables-example">
                    <thead>
                    <tr>
                        <th>评分时间</th>
                        <th>作品名称</th>
                        <th>评分</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="item : ${data}">
                        <!-- 评分时间，格式化显示 -->
                        <td th:text="${#dates.format(item.scoreTime, 'yyyy-MM-dd HH:mm:ss')}"></td>
                        <!-- 作品名称，假设CompScore实体中有workName属性 -->
                        <td th:text="${item.workId}"></td>
                        <!-- 评分值 -->
                        <td th:text="${item.score}"></td>
                        <!-- 操作列 -->
                        <td>
                            <a th:href="@{/comp/score/remove(id=${item.id})}" class="btn btn-danger btn-xs" onclick="return confirm('确定要删除这条记录吗？')">删除</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    $(function() {
        // 初始化数据表格
        $('.dataTables-example').DataTable({
            "paging": true,          // 分页
            "lengthChange": true,    // 显示每页条数选择
            "searching": true,       // 搜索
            "ordering": true,        // 排序
            "info": true,            // 显示信息
            "autoWidth": false,      // 关闭自动宽度
            "language": {
                "sProcessing": "处理中...",
                "sLengthMenu": "显示 _MENU_ 条记录",
                "sZeroRecords": "没有匹配的记录",
                "sInfo": "显示第 _START_ 至 _END_ 条，共 _TOTAL_ 条记录",
                "sInfoEmpty": "显示第 0 至 0 条，共 0 条记录",
                "sInfoFiltered": "(从 _MAX_ 条记录中过滤)",
                "sSearch": "搜索:",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上页",
                    "sNext": "下页",
                    "sLast": "末页"
                }
            }
        });
    });
</script>
</body>
</html>